package com.itheima.array;

/**
 * @Author 王加鑫
 * @Date 2021/4/20 16:06
 * @Version 1.0
 * 如何求数组中所有元素的和呢?
 */
public class arrayTest03 {
    public static void main(String[] args) {
        int[] num = {10,20,30};
        //累加和
        int sum = 0;
        for (int i = 0; i < num.length; i++) {
            System.out.println(num[i]);
            sum+=num[i];
        }
        System.out.println("数组所有元素的和为:"+sum);
    }
}
